package com.yc.jpyy.vehicle.controller;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSON;
import com.common.utils.manydatasource.HandlerDataSource;
import com.yc.jpyy.base.bean.RestResponse;
import com.yc.jpyy.base.controller.BaseController;
import com.yc.jpyy.utils.Tools;
import com.yc.jpyy.vehicle.dao.VehicleDao;
import com.yc.jpyy.vehicle.service.VehicleService;


@Controller
@RequestMapping(value = "/vehicle")
@Scope("prototype")
public class VehicleController extends BaseController{
	private static Logger logger = LoggerFactory.getLogger(VehicleController.class);

	@Autowired
	private VehicleService vehicleService; 

	@Autowired
	private VehicleDao vehicleDao;
	
	/**
	 * 插入车辆
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/addVehicle", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String addVehicle(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {
			/*//获取流
			InputStream is = request.getInputStream();  
			byte[] bytes = new byte[1024 * 1024]; 
			int nRead = 1;  
			int nTotalRead = 0;  
			while (nRead > 0) {  
			    nRead = is.read(bytes, nTotalRead, bytes.length - nTotalRead);  
			    if (nRead > 0)  
			        nTotalRead = nTotalRead + nRead;  
			} 
			//读取的字节流转换成字符串
			String info = new String(bytes, 0, nTotalRead, "utf-8");  */
			String info = request.getAttribute("info").toString();
			Map<String,Object> paramsMap = Tools.JsonToMap(info);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			//byte[] sb = paramsMap.get("vehiclepicture").toString().getBytes();
			//Byte[] imgbtye = (Byte[]) paramsMap.get("vehiclepicture");
			//BASE64Decoder decoder = new BASE64Decoder();
			//Base64解码  
	        //byte[] b = decoder.decodeBuffer(Optional.ofNullable(paramsMap.get("vehiclepicture")).orElse("").toString());  
	        //for(int i=0;i<b.length;++i)  
	        //{  
	            //if(b[i]<0)  
	            //{//调整异常数据  
	                //b[i]+=256;  
	            //}   
	        //}  
			//paramsMap.put("vehiclepicture", b);
			resultMap = vehicleService.addVehicle(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("addVehicle" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "添加失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	/**
	 * 根据参数查询车辆
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/queryVehicle", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String queryVehicle(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {	
			//HandlerDataSource.setDataSource("bizDataSource");
			String queryParameter = request.getParameter("info"); 
			Map<String,Object> paramsMap = Tools.JsonToMap(queryParameter);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			resultMap = vehicleService.queryVehicle(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("queryVehicle" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "查询失败");
			//resultMap.put("exception", "queryVehicle" + e.toString());
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	/**
	 * 更新车辆
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/updateVehicle", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String updateVehicle(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {
			/*//获取流
			InputStream is = request.getInputStream();  
			byte[] bytes = new byte[1024 * 1024]; 
			int nRead = 1;  
			int nTotalRead = 0;  
			while (nRead > 0) {  
			    nRead = is.read(bytes, nTotalRead, bytes.length - nTotalRead);  
			    if (nRead > 0)  
			        nTotalRead = nTotalRead + nRead;  
			} 
			//读取的字节流转换成字符串
			String updateParameter = new String(bytes, 0, nTotalRead, "utf-8");*/
			String info = request.getAttribute("info").toString();
			//HandlerDataSource.setDataSource("bizDataSource");
			Map<String,Object> paramsMap = Tools.JsonToMap(info);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			//BASE64Decoder decoder = new BASE64Decoder();
			//Base64解码  
			/*
	        byte[] b = decoder.decodeBuffer(Optional.ofNullable(paramsMap.get("vehiclepicture")).orElse("").toString());  
	        for(int i=0;i<b.length;++i)  
	        {  
	            if(b[i]<0)  
	            {//调整异常数据  
	                b[i]+=256;  
	            }   
	        }  
	        
			paramsMap.put("vehiclepicture", b);
			*/
			resultMap = vehicleService.updateVehicle(paramsMap);	
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("updateVehicle" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "更新失败");
			//resultMap.put("exception", "updateVehicle" + e.toString());
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	
	/**
	 * 车辆重复检查
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/checkVehicleId", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String checkVehicleId(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {
			//HandlerDataSource.setDataSource("bizDataSource");
			String checkParameter= request.getParameter("info");
			Map<String,Object> paramsMap = Tools.JsonToMap(checkParameter);
			//默认执行总库中的视图
			HandlerDataSource.setDataSource("A1");
			resultMap = vehicleService.checkVehicleId(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("checkVehicleId" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "查询失败");
			//resultMap.put("exception", "checkVehicleId" + e.toString());
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	/**
	 * 查询车辆详情
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/queryVehicleById", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String queryVehicleById(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {
			String queryParameter= request.getParameter("info");
			Map<String,Object> paramsMap = Tools.JsonToMap(queryParameter);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			resultMap = vehicleService.queryVehicleById(Integer.parseInt(paramsMap.get("id").toString()));
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("queryVehicleById" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "查询失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	/**
	 * 更新审核接口
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/updateForCheck", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String updateForCheck(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {
			//HandlerDataSource.setDataSource("bizDataSource");
			String updateParameter= request.getParameter("info");
			Map<String,Object> paramsMap = Tools.JsonToMap(updateParameter);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			resultMap = vehicleService.updateForCheck(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("updateForCheck" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "更新失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	/**
	 * 更新状态接口
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/updateForStatus", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String updateForStatus(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {
			//HandlerDataSource.setDataSource("bizDataSource");
			String updateParameter= request.getParameter("info");
			Map<String,Object> paramsMap = Tools.JsonToMap(updateParameter);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			paramsMap.put("id", paramsMap.get("id").toString().split(","));
			resultMap = vehicleService.updateForStatus(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("updateForStatus" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "更新失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	/**
	 * 更新是否锁定接口
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/updateForLock", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String updateForLock(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {
			//HandlerDataSource.setDataSource("bizDataSource");
			String updateParameter= request.getParameter("info");
			Map<String,Object> paramsMap = Tools.JsonToMap(updateParameter);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			paramsMap.put("id", paramsMap.get("id").toString().split(","));
			resultMap = vehicleService.updateForLock(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("updateForLock" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "更新失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	/**
	 * 更新图片接口
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/updateForImage", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String updateForImage(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {
			/*//获取流
			InputStream is = request.getInputStream();  
			byte[] bytes = new byte[1024 * 1024]; 
			int nRead = 1;  
			int nTotalRead = 0;  
			while (nRead > 0) {  
			    nRead = is.read(bytes, nTotalRead, bytes.length - nTotalRead);  
			    if (nRead > 0)  
			        nTotalRead = nTotalRead + nRead;  
			} 
			//读取的字节流转换成字符串
			String updateParameter = new String(bytes, 0, nTotalRead, "utf-8"); */
			String info = request.getAttribute("info").toString();
			//HandlerDataSource.setDataSource("bizDataSource");
			Map<String,Object> paramsMap = Tools.JsonToMap(info);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			/*
			BASE64Decoder decoder = new BASE64Decoder();
			//Base64解码  
	        byte[] b = decoder.decodeBuffer(paramsMap.get("vehiclepicture").toString());  
	        for(int i=0;i<b.length;++i)  
	        {  
	            if(b[i]<0)  
	            {//调整异常数据  
	                b[i]+=256;  
	            }   
	        }  
			paramsMap.put("vehiclepicture", b);
			*/
			resultMap = vehicleService.updateForImage(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("updateForImage" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "更新失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	/**
	 * 车辆年审
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 *//*
	@SuppressWarnings("finally")
	@RequestMapping(value = "/vehicleCheckYears", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String vehicleCheckYears(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {	
			//HandlerDataSource.setDataSource("bizDataSource");
			String parameter = request.getParameter("parameter"); 
			Map<String,Object> paramsMap = Tools.JsonToMap(parameter);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			resultMap = vehicleService.vehicleCheckYears(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("vehicleCheckYear" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "年审失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	*/
	/**
	 * 根据车牌号车辆颜色查询车辆详情
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/queryVehicleByNumber", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String queryVehicleByNumber(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {
			String queryParameter= request.getParameter("info");
			Map<String,Object> paramsMap = Tools.JsonToMap(queryParameter);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			resultMap = vehicleService.queryVehicleByNumber(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("queryVehicleByNumber" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "查询失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	
	/**
	 * 车辆年审
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/vehicleCheckYear", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String vehicleCheckYear(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {	
			String parameter = request.getParameter("info"); 
			Map<String,Object> paramsMap = Tools.JsonToMap(parameter);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			resultMap = vehicleService.vehicleCheckYear(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("vehicleCheckYear" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "年审失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	/**
	 * 查询关联车辆
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/queryRelationVehicle", method = { RequestMethod.GET,
			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	public @ResponseBody String queryRelationVehicle(HttpServletRequest request) throws UnsupportedEncodingException {

		Map<String,Object> resultMap = new HashMap<>();
		request.setCharacterEncoding("UTF-8");
		try {	
			//HandlerDataSource.setDataSource("bizDataSource");
			String info = request.getParameter("info"); 
			Map<String,Object> paramsMap = Tools.JsonToMap(info);
			String dbcode = paramsMap.get("dbcode").toString();
			HandlerDataSource.setDataSource(dbcode);
			resultMap = vehicleService.queryRelationVehicle(paramsMap);
			resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
		} catch (Exception e) {
			logger.info("queryRelationVehicle" + e.toString());
			resultMap.put("returnCode", 0);
			resultMap.put("returnMsg", "查询失败");
		} finally {
			HandlerDataSource.clear();
			return JSON.toJSONString(resultMap);
		}
	}
	
	
	//查询单条
		@SuppressWarnings("finally")
		@RequestMapping(value = "/findVehicleByWx", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String findVehicleByWx(HttpServletRequest request) throws UnsupportedEncodingException {

			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				System.out.println("paramsMap"+paramsMap);
				String dbcode = paramsMap.get("dbcode").toString();
			    HandlerDataSource.setDataSource(dbcode);
				Map<String, Object> val = vehicleService.queryVehicleByWx(paramsMap);
				int retSize = val.size();
				if(retSize==0) {
		            response.setReturnMsg(1, "无查询数据");
					return response.toJSON();
				}else {	
					 response.setReturnMsg(1, "查询单条数据成功");
					 response.setListData(val);
					 return response.toJSON();
				}
			} catch (Exception e) {
	            logger.error("查询单条数据异常" + e.toString());
				// 异常信息
	            response.setReturnException(e.toString());
				response.setReturnCode(0);
				response.setReturnMsg("查询单条数据异常");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
		}
		
		/**
		 * 车龄统计接口
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/queryVehicleByPietype", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String queryVehicleByPietype(HttpServletRequest request) throws UnsupportedEncodingException {
			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
	            List<Map<String, Object>> list = vehicleService.queryVehicleByPietype(paramsMap);
	            response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
				return response.toJSON();
	            
			} catch (Exception e) {
				logger.error("queryVehicleByPietype" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
		}
		/**
		 * 车辆里程统计接口
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/selectVehicleCname", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String selectVehicleCname(HttpServletRequest request) throws UnsupportedEncodingException {

			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				List<Map<String, Object>> list = vehicleService.selectVehicleCname(paramsMap);
				response.setReturnMsg(1, "操作成功");
		        response.setListData(list);
		        return response.toJSON();		
			}  catch (Exception e) {
				logger.error("selectVehicleCname" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
		}
		
		/**
		 * 行业营运统计需要的接口
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/queryVehicleByCname", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String queryVehicleByCname(HttpServletRequest request) throws UnsupportedEncodingException {

			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				List<Map<String,Object>> list = vehicleService.queryVehicleByCname(paramsMap);
				response.setReturnMsg(1, "操作成功");
		        response.setListData(list);
		        return response.toJSON();
			}  catch (Exception e) {
				logger.error("queryVehicleByCname" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
		}
		/**
		 * 违法事件类型分布
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/selectEgalBehavoir", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String selectEgalBehavoir(HttpServletRequest request) throws UnsupportedEncodingException {
			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
	            List<Map<String,Object>> list = vehicleService.selectEgalBehavoir(paramsMap);
	            response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
				return response.toJSON();
	            
			} catch (Exception e) {
				logger.error("selectEgalBehavoir" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
			
		}
		/**
		 * 违法事件企业分布
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/seletCompanyNameCount", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String seletCompanyNameCount(HttpServletRequest request) throws UnsupportedEncodingException {
			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
	            List<Map<String,Object>> list = vehicleService.seletCompanyNameCount(paramsMap);
	           /* list.forEach(k->{
	            	k.put("CompanyNameCount", (int)(1+Math.random()*(100-1+1)));
	            });*/
	            
	            
	            response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
				return response.toJSON();
	            
			} catch (Exception e) {
				logger.error("seletCompanyNameCount" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
			
		}
		
		/**
		 * 服务上岗证新增统计、轮训培训统计、违规轮训统计接口
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/seletTrainingCount", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String seletTrainingCount(HttpServletRequest request) throws UnsupportedEncodingException {
			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
	            List<Map<String, Object>> list = vehicleService.seletTrainingCount(paramsMap);
	            response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
				return response.toJSON();
	            
			} catch (Exception e) {
				logger.error("seletTrainingCount" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
		}
		
		/**
		 * 超期轮训统计
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/seletOverdueTrainingCount", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String seletOverdueTrainingCount(HttpServletRequest request) throws UnsupportedEncodingException {
			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
	            List<Map<String, Object>> list = vehicleService.seletOverdueTrainingCount(paramsMap);
	            response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
				return response.toJSON();
	            
			} catch (Exception e) {
				logger.error("seletOverdueTrainingCount" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
		
		}
		
		/**
		 * 企业经营情况统计接口
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/seletCompanyVehicleCount", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String seletCompanyVehicleCount(HttpServletRequest request) throws UnsupportedEncodingException {

			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
	            List<Map<String, Object>> list = vehicleService.seletCompanyVehicleCount(paramsMap);
	            response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
				return response.toJSON();
	            
			} catch (Exception e) {
				logger.error("seletCompanyVehicleCount" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
		
		
		}
		
		/**
		 * 企业订单查询
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/seletCompanyOrderCount", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String seletCompanyOrderCount(HttpServletRequest request) throws UnsupportedEncodingException {
			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
	            List<Map<String,Object>> list = vehicleService.seletCompanyOrderCount(paramsMap);
                response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
				return response.toJSON();
			} catch (Exception e) {
				logger.error("seletCompanyOrderCount" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
			
		}
		/**
		 * 订单统计查询_订单时段分布
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/seletCompanyOrderTimeGroup", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String seletCompanyOrderTimeGroup(HttpServletRequest request) throws UnsupportedEncodingException {
			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
	            List<Map<String,Object>> list = vehicleService.seletCompanyOrderTimeGroup(paramsMap);
	            response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
				return response.toJSON();
			} catch (Exception e) {
				logger.error("seletCompanyOrderTimeGroup" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
		}
		
		/**
		 * 十、服务评价统计，条件时间范围
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/selectServiceEvaluation", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String selectServiceEvaluation(HttpServletRequest request) throws UnsupportedEncodingException {

			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				List<Map<String,Object>> list = vehicleService.selectServiceEvaluation(paramsMap);
				response.setReturnMsg(1, "操作成功");
			    response.setListData(list);
			    return response.toJSON();
			}  catch (Exception e) {
				logger.error("selectServiceEvaluation" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
		}
		
		/**
		 * 车辆运行统计_企业车辆在线统计
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/findCarOnlineCount", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String findCarOnlineCount(HttpServletRequest request) throws UnsupportedEncodingException {
			RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			request.setCharacterEncoding("UTF-8");
			try {
				String info = request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
	            List<Map<String,Object>> list = vehicleService.findCarOnlineCount(paramsMap);
	            response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
		     	return response.toJSON();  
			} catch (Exception e) {
				logger.error("findCarOnlineCount" + e.toString());
				response.setReturnCode(1);
				response.setReturnException(e.toString());
				response.setReturnMsg("查询失败！");
			} finally {
				HandlerDataSource.clear();
				return response.toJSON();
			}
			
		}
		
		/**
		 * 根据brandtype查询车辆总数
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/getCountByBrandType", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String getCountByBrandType(HttpServletRequest request) throws UnsupportedEncodingException {

			Map<String,Object> resultMap = new HashMap<>();
			request.setCharacterEncoding("UTF-8");
			try {	
				String info = request.getParameter("info"); 
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				resultMap = vehicleService.getCountByBrandType(paramsMap);
				resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			} catch (Exception e) {
				logger.info("getCountByBrandType" + e.toString());
				resultMap.put("returnCode", 0);
				resultMap.put("returnMsg", "查询失败");
			} finally {
				HandlerDataSource.clear();
				return JSON.toJSONString(resultMap);
			}
		}
		
		
		/**
		 * 根据参数查询车辆主键，车牌号及颜色
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/queryVehicleInfo", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String queryVehicleInfo(HttpServletRequest request) throws UnsupportedEncodingException {

			Map<String,Object> resultMap = new HashMap<>();
			request.setCharacterEncoding("UTF-8");
			try {	
				String info = request.getParameter("info"); 
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				resultMap = vehicleService.queryVehicleInfo(paramsMap);
				resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			} catch (Exception e) {
				logger.info("queryVehicleInfo" + e.toString());
				resultMap.put("returnCode", 0);
				resultMap.put("returnMsg", "查询失败");
			} finally {
				HandlerDataSource.clear();
				return JSON.toJSONString(resultMap);
			}
		}
		
		/**
		 * 重置司机的车辆
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/resetDriverCarRelation", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String resetDriverCarRelation(HttpServletRequest request) throws UnsupportedEncodingException {

			Map<String,Object> resultMap = new HashMap<>();
			request.setCharacterEncoding("UTF-8");
			try {
				String updateParameter= request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(updateParameter);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				resultMap = vehicleService.resetDriverCarRelation(paramsMap);
				resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			} catch (Exception e) {
				logger.info("updateForCheck" + e.toString());
				resultMap.put("returnCode", 0);
				resultMap.put("returnMsg", "操作失败");
			} finally {
				HandlerDataSource.clear();
				return JSON.toJSONString(resultMap);
			}
		}
		
		/**
		 * 公司车辆情况统计报表
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/getVehicleCountInfo", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String getVehicleCountInfo(HttpServletRequest request) throws UnsupportedEncodingException {

			Map<String,Object> resultMap = new HashMap<>();
			request.setCharacterEncoding("UTF-8");
			try {
				String queryParameter= request.getParameter("info");
				Map<String,Object> paramsMap = Tools.JsonToMap(queryParameter);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				resultMap = vehicleService.getVehicleCountInfo(paramsMap);
				resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			} catch (Exception e) {
				logger.info("getvehicleCountInfo" + e.toString());
				resultMap.put("returnCode", 0);
				resultMap.put("returnMsg", "查询失败");
			} finally {
				HandlerDataSource.clear();
				return JSON.toJSONString(resultMap);
			}
		}
		
		//公司租赁车辆查询
	   	@SuppressWarnings("finally")
	   	@RequestMapping(value = "/findVehicleToCarRental", method = { RequestMethod.GET,
	   			RequestMethod.POST }, produces = "application/json; charset=utf-8")
	   	public @ResponseBody String findVehicleToCarRental(HttpServletRequest request) throws UnsupportedEncodingException {

	   		RestResponse response = new RestResponse(Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
	   		request.setCharacterEncoding("UTF-8");
	   		try {
	   			String info = request.getParameter("info");
	   			System.out.println("info"+info);
	   			Map<String,Object> paramsMap = Tools.JsonToMap(info);
	   			String dbcode = paramsMap.get("dbcode").toString();
	   			//设置数据源
	   			HandlerDataSource.setDataSource(dbcode);
	   			
	   			if(Tools.isNotEmpty(paramsMap.get("vehiclestatus"))) {
	   				String vehiclestatus =	paramsMap.get("vehiclestatus").toString();
	   			    String[] idarray = vehiclestatus.split(",");
					paramsMap.put("idarray", idarray);
	   			}
	   			List<Map<String, Object>> list = vehicleService.findVehicleToCarRentalService(paramsMap);
	            response.setReturnMsg(1, "操作成功");
	            response.setListData(list);
	   			return response.toJSON();
	               
	   		} catch (Exception e) {
	   			logger.error("findVehicleToCarRental" + e.toString());
	   			response.setReturnCode(1);
	   			response.setReturnMsg("查询失败");
	   			response.setReturnException(e.toString());
	   		} finally {
	   			HandlerDataSource.clear();
	   			return response.toJSON();
	   		}
	   	}
	   	/**
		 * 根据参数查询车辆主键，车牌号及颜色(查询所有库，视图实现)
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/queryAllVehicleInfo", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String queryAllVehicleInfo(HttpServletRequest request) throws UnsupportedEncodingException {

			Map<String,Object> resultMap = new HashMap<>();
			request.setCharacterEncoding("UTF-8");
			try {	
				String info = request.getParameter("info"); 
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				resultMap = vehicleService.queryAllVehicleInfo(paramsMap);
				resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			} catch (Exception e) {
				logger.info("queryAllVehicleInfo" + e.toString());
				resultMap.put("returnCode", 0);
				resultMap.put("returnMsg", "查询失败");
			} finally {
				HandlerDataSource.clear();
				return JSON.toJSONString(resultMap);
			}
		}
		
		/**
		 * 添加锁定
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/addLockForVehicle", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String addLockForVehicle(HttpServletRequest request) throws UnsupportedEncodingException {

			Map<String,Object> resultMap = new HashMap<>();
			request.setCharacterEncoding("UTF-8");
			try {	
				String info = request.getParameter("info"); 
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				resultMap = vehicleService.addLockForVehicle(paramsMap);
				resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			} catch (Exception e) {
				logger.info("addLockForVehicle" + e.toString());
				resultMap.put("returnCode", 0);
				resultMap.put("returnMsg", "添加锁定失败");
			} finally {
				HandlerDataSource.clear();
				return JSON.toJSONString(resultMap);
			}
		}
		
		/**
		 * 解除锁定
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/unlockForVehicle", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String unlockForVehicle(HttpServletRequest request) throws UnsupportedEncodingException {

			Map<String,Object> resultMap = new HashMap<>();
			request.setCharacterEncoding("UTF-8");
			try {	
				String info = request.getParameter("info"); 
				Map<String,Object> paramsMap = Tools.JsonToMap(info);
				String dbcode = paramsMap.get("dbcode").toString();
				HandlerDataSource.setDataSource(dbcode);
				resultMap = vehicleService.unlockForVehicle(paramsMap);
				resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			} catch (Exception e) {
				logger.info("unlockForVehicle" + e.toString());
				resultMap.put("returnCode", 0);
				resultMap.put("returnMsg", "解除锁定失败");
			} finally {
				HandlerDataSource.clear();
				return JSON.toJSONString(resultMap);
			}
		}
		
		
		/**
		 * 查询所有库车辆
		 * 
		 * @param request
		 * @return
		 * @throws UnsupportedEncodingException
		 */
		@SuppressWarnings("finally")
		@RequestMapping(value = "/queryAllVehicle", method = { RequestMethod.GET,
				RequestMethod.POST }, produces = "application/json; charset=utf-8")
		public @ResponseBody String queryAllVehicle(HttpServletRequest request) throws UnsupportedEncodingException {

			Map<String,Object> resultMap = new HashMap<>();
			request.setCharacterEncoding("UTF-8");
			try {	
				//HandlerDataSource.setDataSource("bizDataSource");
				String queryParameter = request.getParameter("info"); 
				Map<String,Object> paramsMap = Tools.JsonToMap(queryParameter);
				HandlerDataSource.setDataSource("A1");
				resultMap = vehicleService.queryAllVehicle(paramsMap);
				resultMap.put("pubKey",Optional.ofNullable(request.getAttribute("pubKey")).orElse(""));
			} catch (Exception e) {
				logger.info("queryAllVehicle" + e.toString());
				resultMap.put("returnCode", 0);
				resultMap.put("returnMsg", "查询失败");
			} finally {
				HandlerDataSource.clear();
				return JSON.toJSONString(resultMap);
			}
		}
			
}
